(function () {

    class Person {
        // 添加属性修饰符
        /**
         * public 公共属性，任意位置访问、修改
         * private 私有属性，只能类内部修改
         * protected 包含属性，只能在当前类和继承类中使用
         */
        private name: string
        age: number
        private _gender: string = 'defalut'
        constructor(name: string, age: number) {
            this.name = name
            this.age = age
        }
        getName() {
            return this.name
        }
        setName(name: string) {
            this.name = name
        }

        // 简写get、set
        get gender() {
            return this._gender
        }

        set gender(g) {
            console.log('赋值gender')
            this._gender = g
        }
    }

    const per = new Person('张三', 18)

    console.log(per)
    per.setName('李四')
    console.log(per.getName())
    console.log(per.age)
    console.log(per.gender)
    per.gender = 'new'
    console.log(per.gender)

    // 简写属性
    class P {
        constructor(public name: string, public age: number) { }
    }
    const p1 = new P('李四', 20)
    console.log(p1)
})();
